<?php

function reequipment_adminapi_deleteschedule($args)
{
    // Get arguments from argument array
    extract($args);
    // Argument check
    if (!isset($schedule_id)) {
        $msg = xarML('Invalid Parameter Count');
        xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM', new SystemException($msg));
        return;
    }

    // The user API function is called
    $test_id = xarModAPIFunc('reequipment',
                          'user',
                          'getschedule',
                          array('schedule_id' => $schedule_id));
    if ($test_id == false) return;

    // Get datbase setup
    $dbconn =& xarDBGetConn();
    $xartable =& xarDBGetTables();
    $table = $xartable['rescheduled'];

    // Delete the item
    $query = "DELETE FROM $table
            WHERE schedule_id = ?";
    $bindvars = array($schedule_id);
    $result =& $dbconn->Execute($query,$bindvars);
    if (!$result) return;
    // Let any hooks know that we have deleted a link
    $args['module'] = 'reequipment';
    $args['itemtype'] = 3; //tag
    $args['itemid'] = $schedule_id;
    xarModCallHooks('item', 'delete', $schedule_id, $args);
    // Let the calling process know that we have finished successfully
    return true;
}
?>